<!DOCTYPE html>
<html lang="en">
	<head>
		<title>购物车</title>
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	</head>
	<body>
		<table>
			<tr>
				<td>CHECK</td>
				<td>ID</td>
				<td>NAME</td>
				<td>NUM</td>
				<td>PRICE</td>
				<td>SHOPNAME</td>
			</tr>
			<%for(item in items){%>
				<tr>
					<td>
					<input class="cb" data-id="${item.id}"
					<% 
						if(item.is_checked==1){ 
							print(" checked='checked' ");
							print(" data-checked='1' "); 
						}else{
							print(" data-checked='0' "); 
						}
					 %>
					  type="checkbox"/>
					</td>
					<td>${item.goods_sku_id}</td>
					<td>${item.name}</td>
					<td>${item.goods_number}</td>
					<td>${item.price}</td>
					<td>${item.shopname}</td>
				</tr>
			<%}%>
		</table>
		
		<a href="index">Return</a> &nbsp;<a href="checkout">GOON</a>
	</body>
</html>
<script src="http://cdn.bootcss.com/jquery/2.1.3/jquery.js"></script>
<script type="text/javascript">
<!--

$(function(){
	$(".cb").click(function(){
		var dataId = $(this).attr("data-id");
		var isChecked = $(this).attr("data-checked");
		if(isChecked==0){
			$(this).attr("data-checked",1);
			isChecked = 1;
		}else{
			$(this).attr("data-checked",0);
			isChecked = 0;
		}
		updateItemChecked(dataId,isChecked);
	});
});

function updateItemChecked(id,isChecked){
	$.post("${ctx!}/cart/updateItemChecked", { id: id, is_checked:isChecked },
	 function(data){
		eval('var data = ' + data + ';');
		if(data.success) {
			// alert("success");
		}
	 },"text");
}



//-->
</script>
